<?php
$this->pageTitle = 'Manage Front-End Users ';

$this->menu = array(
    array('label'=>Yii::t('app', 'Download Newsletter List ') . ' ' . $model->label(2), 'url'=>array('newsLetter')),
    array('label' => Yii::t('app', 'Create') . ' ' . $model->label(), 'url' => array('create')),
);
?>

<h3><?php echo Yii::t('app', 'Manage') . ' ' . GxHtml::encode($model->label(2)); ?></h3>
<div class="alert alert-success">Mail Send successfully.</div>
<style>
    .alert-success{
        display:none;
    }

</style>
<!-- search-form -->
<script>
    function sendmailtouser(id){      
        $.ajax({
            url: "<?php echo $this->createAbsoluteUrl('users/sendmail'); ?>",
            type: "post",
            data: "id=" + id,
            dataType: "html",
            success: function(result) {               
                if(result==1){                   
                    $(".alert-success").show();    
                }

            }
        });
    }</script>
<script type="text/javascript">
    function ChangeStatus(id, status){
        $.ajax({
            url: "<?php echo $statusChangeUrl; ?>",
            type: "post",
            data: "id=" + id + "&status=" + status,
            dataType: "html",
            success: function(msg) {
                $('#users-grid').yiiGridView.update('users-grid');

            }
        });

    }


</script>



<?php
$this->widget('zii.widgets.grid.CGridView', array(
    'id' => 'users-grid',
    'dataProvider' => $model->Search(),
    'filter' => $model,
    'columns' => array(
        array('name' => 'username',
            'type' => 'raw',
            'value' => 'CHtml::link($data->username,array("users/viewClassCourse","id"=>$data->id))'),
        array(
            'name' => 'status',
            'type' => 'raw',
            'value' => 'changeStatusIngridView($data)',
            'filter' => array('0' => Yii::t('app', 'Inactive'), '1' => Yii::t('app', 'Active')),
        ),
        array(
            'header' => 'Review and Rating',
            'value' => 'Users::getTrainerProfileReview($data->id)',
            'type' => 'raw',
            'filter' => false,
        ),
        array(
            'name' => 'createtime',
            'header' => 'Created',
            'value' => 'Yii::app()->dateFormatter->format("d MMM y",$data->createtime)',
            'filter' => false,
        ),
        array(
            'name' => 'lastvisit',
            'header' => 'Last Visit',
            'value' => '(!empty($data->lastvisit))?Yii::app()->dateFormatter->format("d MMM y",$data->lastvisit):"No Visist"',
            'filter' => false,
        ),
        array(
            'name' => 'id',
            'type' => 'raw',
            'header' => 'Send details',
            'value' => 'CHtml::link("Send details", "javascript:void(0)", array("id"=>$data->id,"class"=>"sendmailtouser","onclick"=>"sendmailtouser(this.id)"))',
            'filter' => false,
        ),
        array(
            'class' => 'CButtonColumn',
            'template' => '{view}{update}',
        ),
    ),
));
?>
